package com.ss.android.article.browser.view.user.a;

import android.content.Context;
import android.support.annotation.NonNull;
import android.support.v7.widget.RecyclerView.Adapter;
import android.support.v7.widget.RecyclerView.ViewHolder;
import android.view.LayoutInflater;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.a.a.aa;
import com.a.a.e;
import com.a.a.s;
import com.ss.android.article.browser.R;
import com.ss.android.article.browser.a.c;
import com.ss.android.article.browser.database.BrowserHistory;

import java.util.ArrayList;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

public final class a extends Adapter {
    final class a$a extends ViewHolder {
        final ImageView a;
        final TextView b;
        protected final a c;

        a$a(a arg3, LayoutInflater arg4, ViewGroup arg5) {
            super(arg4.inflate(R.layout.ef, arg5, false));
            this.c = arg3;
            this.a = this.itemView.findViewById(com.ss.android.article.browser.R.id.icon);
            this.b = this.itemView.findViewById(com.ss.android.article.browser.R.id.title);
        }
    }

    public final ArrayList a;
    private final LayoutInflater b;
    @NonNull
    private final Map c;
    private final com.ss.android.article.browser.a.a d;

    public a(Context arg2) {
        this.a = new ArrayList();
        this.c = new ConcurrentHashMap();
        this.b = LayoutInflater.from(arg2);
        this.d = com.ss.android.article.browser.a.a.a();
    }

    static Map a(a arg1) {
        return arg1.c;
    }

    public final int getItemCount() {
        return this.a.size();
    }

    public final void onBindViewHolder(ViewHolder arg6, int arg7) {
        Object v0 = this.a.get(arg7);
        ((a$a) arg6).b.setText(((BrowserHistory) v0).title);
        if (!((BrowserHistory) v0).h) {
            if (((BrowserHistory) v0).d == null) {
                ((a$a) arg6).a.setTag(Integer.valueOf(((BrowserHistory) v0).url.hashCode()));
                String v2 = ((BrowserHistory) v0).url;
                Object v1 = ((a$a) arg6).c.c.get(v2);
                if (v1 != null) {
                    ((aa) v1).b();
                }

                s v1_1 = s.a(new c(((a$a) arg6).c.d, v2, ((BrowserHistory) v0).title));
                ((e) v1_1).b = android.support.design.a.c();
                ((e) v1_1).c = android.support.design.a.b();
                ((a$a) arg6).c.c.put(v2, v1_1.a(new b(((a$a) arg6), v2, ((BrowserHistory) v0))));
            } else {
                ((a$a) arg6).a.setImageBitmap(((BrowserHistory) v0).d);
            }
        }
    }

    public final ViewHolder onCreateViewHolder(ViewGroup arg3, int arg4) {
        return new a$a(this, this.b, arg3);
    }
}

